<template>
  <div class="app-container">
    <el-table
      :data="workOrderDescribeValueList"
      style="width: 100%"
    >
      <el-table-column
        prop="name"
        :label="$t('name')"
      />
      <el-table-column
        prop="value"
        :label="$t('value')"
      />
      <el-table-column
        :label="$t('time')"
      >
        <template slot-scope="scope">
          <i class="el-icon-time" />
          <span style="margin-left: 13px">{{
            formatDate(scope.row.createdDate)
          }}</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import { formatDate } from '@/util/common'
import { listWorkOrderDescribeValue } from '@/api/erp/erpWorkOrderDescribeValueApi'

export default {
  name: 'WorkOrderDescribeValue',
  props: {
    workOrder: {
      type: Object,
      default: null
    }
  },
  data() {
    return {
      workOrderDescribeValueList: []
    }
  },
  watch: {
    workOrder: {
      deep: true,
      handler() {
        this.listWorkOrderDescribeValue()
      }
    }
  }, created() {
    this.listWorkOrderDescribeValue()
  },
  methods: {
    formatDate(time) {
      return formatDate(this, time)
    },
    listWorkOrderDescribeValue() {
      listWorkOrderDescribeValue({
        workOrderId: this.workOrder.workOrderId
      }).then(res => {
        const { code, data } = res
        if (code === '200') {
          this.workOrderDescribeValueList = data
        } else {
          this.workOrderDescribeValueList = []
        }
      })
    }
  }
}
</script>

